package com.zr.inquiry.mapper;

import com.zr.inquiry.model.*;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import javax.validation.Valid;
import java.util.List;

/**
 * Created by 天赐 on 2019/12/27.
 */
@Mapper
public interface InquiryMapper {

    @Select("select * from legalperson where legalPersonId=#{legalPersonId}")
    legalperson queryById(Integer legalPersonId);

    List<Supplier> getSupplier(String legalPersonCode);

    List<inquiryend> getPage(inquirytotal inquirytotal);

    int getCount(inquirytotal inquirytotal);

    List<Supplier> getSupPage(SupplierPage supplierPage);

    int getSupCount(SupplierPage supplierPage);

    List<Spare> getSparePage(SparePage sparePage);

    int getSpareCount(SparePage sparePage);

    @Update("update inquirytotal set inquiryStatus=#{orderStatus} where requestForQuotationId=#{requestForQuotationId}")
    void updateInquiry(InquiryDelete inquiryDelete);
    @Select("select * from inquirytotal where requestForQuotationId=#{requestForQuotationId}")
    inquirytotal queryByrequestId(String requestForQuotationId);
    @Select("select * from inquirytotal where requestForQuotationId=#{requestForQuotationId}")
    List<inquirytotal> queryByRid(String requestForQuotationId);

    inquiryend seeInquiryTotal(Integer id);

    List<InquirySpare> seeSpareInquiry(Integer id);

    List<InquirySupplier> seeSupInquier(Integer id);
    @Update("update inquirytotal set auditorExplain=#{auditorExplain},auditorStatus=#{auditorStatus},auditorTime=#{auditorTime} where requestForQuotationId=#{requestForQuotationId}")
    int shenHe(@Valid ShenHeInquiry shenHeInquiry);
    @Update("update inquirytotal set inquiryStatus=#{inquiryStatus} where requestForQuotationId=#{requestForQuotationId} ")
    int updateStatus(StatusUpdate statusUpdate);
    @Update("update inquirytotal set approverExplain=#{approverExplain},approverStatus=#{approverStatus},approverTime=#{approverTime} where requestForQuotationId=#{requestForQuotationId}")
    int pass(PassInquiry passInquiry);
    @Delete("delete from inquirysparedetail where inquiryId=#{inid}")
    void deleteInSpare(int inid);
    @Delete("delete from inquirysupplierdetail where inquiryId=#{inid}")
    void deleteInSupplier(int inid);

    int insertInSpare(List<InquirySpare> spareList);

    int insertInSup(List<InquirySupplier> supplierList);
    @Update("update inquirytotal set currencyCode=#{currencyCode},createTime=#{createTime},endTime=#{endTime} where requestForQuotationId=#{requestForQuotationId}")
    int updateInquiryTotal(inquiryend inquiry);

    List<String> queryBySpCode(List<String> splist);

    List<String> queryBySupCode(List<String> suplist);

    List<SpareSupplier> querySpareSupByCodeList(List<String> splist);
    @Select("select * from legalperson where legalPersonId=#{legalPersonId}")
    legalperson queryByPersonId(Integer legalPersonId);

    void addInquiryTotal(@Valid inquiryend inquiry);

    List<SpareSupplier> querySpareSupByVenCodeList(List<String> suplist);
}
